/*
 * 项目名称:    wms-server-jeecg
 * 创建人员:    DongPeng
 * 创建时间:    2023-09-21
 * copyright(c) 2022 无锡星智数服科技有限公司
 */
package org.jeecg.modules.dock.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.dock.aspect.DockLog;
import org.jeecg.modules.dock.constant.SystemConstants;
import org.jeecg.modules.dock.entity.dto.request.BaseRequestDTO;
import org.jeecg.modules.dock.entity.dto.request.CoilStockDetail;
import org.jeecg.modules.dock.entity.dto.response.WmsResult;
import org.jeecg.modules.dock.entity.ems.request.CuttingPaperReturnTubeRequestVO;
import org.jeecg.modules.dock.entity.ems.request.ForceCompleteReuqestVO;
import org.jeecg.modules.dock.entity.ems.response.EmsBaseResponseVO;
import org.jeecg.modules.dock.service.EmsDockingService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提供Ems调用
 *
 * @author DongPeng
 * @version 1.0.0
 * @date 2023-09-21
 * @description 类描述
 */
@Slf4j
@RestController
@RequestMapping("dock/ems")
@RequiredArgsConstructor
@Api(tags = "ems业务调用模块")
@DockLog(source = SystemConstants.EMS)
public class EmsDockingController {

    private final EmsDockingService emsDockingService;

    @ApiOperation(value = "WMS-EMS发送纵剪/横剪退纸筒请求", notes = "WMS-EMS发送纵剪/横剪退纸筒请求")
    @PostMapping("/cuttingPaperReturnTube")
    public EmsBaseResponseVO cuttingPaperReturnTube(@RequestBody CuttingPaperReturnTubeRequestVO vo) {
        emsDockingService.cuttingPaperReturnTube(vo);
        return EmsBaseResponseVO.ok();
    }

    @ApiOperation(value = "强制完成", notes = "强制完成")
    @PostMapping("/forceComplete")
    public EmsBaseResponseVO forceComplete(@RequestBody ForceCompleteReuqestVO vo) {
        emsDockingService.forceComplete(vo);
        return EmsBaseResponseVO.ok();
    }


    /**
     * 任务状态更新
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.dto.response.WmsResult
     * @author FangYongliang
     * @since 2023/9/25 13:03:25
     */
    @ApiOperation(value = "任务状态更新", notes = "任务状态更新")
    @PostMapping("/serviceInteraction")
    public EmsBaseResponseVO serviceInteraction(@RequestBody TaskTypeUpdateParam param) {
        emsDockingService.serviceInteraction(param);
        return EmsBaseResponseVO.ok();
    }


    /**
     * 纸筒入库明细
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.dto.response.WmsResult
     * @author FangYongliang
     * @since 2023/9/25 13:03:25
     */
    @ApiOperation(value = "纸筒入库明细", notes = "纸筒入库明细")
    @PostMapping("/putBucketDetail")
    public EmsBaseResponseVO putBucketDetail(@RequestBody BaseRequestDTO<CoilStockDetail> param) {
        emsDockingService.putBucketDetail(param);
        return EmsBaseResponseVO.ok();
    }


    @Data
    @ToString(callSuper = true)
    public static class TaskTypeUpdateParam extends BaseRequestDTO<Object> {

        /**
         * 操作原因
         */
        private String operateReason;
    }
}
